<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片编辑器</title>
    <!-- 防止favicon.ico 404错误 -->
    <link rel="icon" href="data:,">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: #f5f5f5;
            overflow: hidden;
        }

        .container {
            display: flex;
            height: 100vh;
        }

        .sidebar {
            width: 250px;
            background: #2c3e50;
            color: white;
            padding: 20px;
            overflow-y: auto;
        }

        .sidebar h2 {
            margin-bottom: 20px;
            font-size: 18px;
            border-bottom: 2px solid #3498db;
            padding-bottom: 10px;
        }

        .tool-section {
            margin-bottom: 30px;
        }

        .tool-section h3 {
            margin-bottom: 15px;
            font-size: 14px;
            color: #ecf0f1;
        }

        .btn {
            display: block;
            width: 100%;
            padding: 10px;
            margin-bottom: 10px;
            background: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            transition: background 0.3s;
        }

        .btn:hover {
            background: #2980b9;
        }

        .btn.active {
            background: #e74c3c;
        }

        .filter-controls {
            display: none;
        }

        .filter-controls.active {
            display: block;
        }

        .slider-group {
            margin-bottom: 15px;
        }

        .slider-group label {
            display: block;
            margin-bottom: 5px;
            font-size: 12px;
        }

        .slider {
            width: 100%;
            margin-bottom: 5px;
        }

        .slider-value {
            font-size: 12px;
            color: #bdc3c7;
        }

        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .toolbar {
            background: white;
            padding: 10px 20px;
            border-bottom: 1px solid #ddd;
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .toolbar button {
            padding: 8px 15px;
            background: #3498db;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
        }

        .toolbar button:hover {
            background: #2980b9;
        }

        .canvas-container {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #ecf0f1;
            position: relative;
        }

        #imageCanvas {
            border: 2px dashed #bdc3c7;
            background: white;
            max-width: 90%;
            max-height: 90%;
        }

        .crop-overlay {
            position: absolute;
            border: 2px solid #3498db;
            background: rgba(52, 152, 219, 0.1);
            display: none;
            cursor: move;
        }

        .crop-handle {
            position: absolute;
            width: 10px;
            height: 10px;
            background: #3498db;
            border: 2px solid white;
            border-radius: 50%;
        }

        .crop-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
        .crop-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
        .crop-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
        .crop-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

        .drop-zone {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: #7f8c8d;
            font-size: 18px;
            pointer-events: none;
        }

        .drop-zone.hidden {
            display: none;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <h2>图片编辑器</h2>
            
            <div class="tool-section">
                <h3>文件操作</h3>
                <button class="btn" id="openBtn">打开图片</button>
                <button class="btn" id="saveBtn">保存图片</button>
            </div>

            <div class="tool-section">
                <h3>编辑工具</h3>
                <button class="btn" id="cropBtn">裁剪</button>
                <button class="btn" id="rotateBtn">旋转</button>
                <button class="btn" id="flipBtn">翻转</button>
                <button class="btn" id="resetBtn">重置</button>
            </div>

            <div class="tool-section">
                <h3>滤镜效果</h3>
                <button class="btn" id="brightnessBtn">亮度</button>
                <button class="btn" id="contrastBtn">对比度</button>
                <button class="btn" id="saturationBtn">饱和度</button>
                <button class="btn" id="blurBtn">模糊</button>
                <button class="btn" id="sepiaBtn">复古</button>
                <button class="btn" id="grayscaleBtn">黑白</button>
            </div>

            <div class="filter-controls" id="brightnessControls">
                <div class="slider-group">
                    <label>亮度</label>
                    <input type="range" class="slider" id="brightnessSlider" min="-100" max="100" value="0">
                    <div class="slider-value" id="brightnessValue">0</div>
                </div>
            </div>

            <div class="filter-controls" id="contrastControls">
                <div class="slider-group">
                    <label>对比度</label>
                    <input type="range" class="slider" id="contrastSlider" min="-100" max="100" value="0">
                    <div class="slider-value" id="contrastValue">0</div>
                </div>
            </div>

            <div class="filter-controls" id="saturationControls">
                <div class="slider-group">
                    <label>饱和度</label>
                    <input type="range" class="slider" id="saturationSlider" min="-100" max="100" value="0">
                    <div class="slider-value" id="saturationValue">0</div>
                </div>
            </div>

            <div class="filter-controls" id="blurControls">
                <div class="slider-group">
                    <label>模糊</label>
                    <input type="range" class="slider" id="blurSlider" min="0" max="20" value="0">
                    <div class="slider-value" id="blurValue">0</div>
                </div>
            </div>
        </div>

        <div class="main-content">
            <div class="toolbar">
                <button id="undoBtn">撤销</button>
                <button id="redoBtn">重做</button>
                <button id="zoomInBtn">放大</button>
                <button id="zoomOutBtn">缩小</button>
                <button id="fitBtn">适应窗口</button>
            </div>

            <div class="canvas-container" id="canvasContainer">
                <canvas id="imageCanvas"></canvas>
                <div class="crop-overlay" id="cropOverlay">
                    <div class="crop-handle nw"></div>
                    <div class="crop-handle ne"></div>
                    <div class="crop-handle sw"></div>
                    <div class="crop-handle se"></div>
                </div>
                <div class="drop-zone" id="dropZone">
                    <div>拖拽图片到此处</div>
                    <div style="font-size: 14px; margin-top: 10px;">或点击"打开图片"按钮</div>
                </div>
            </div>
        </div>
    </div>

    <script src="src/renderer.js"></script>
</body>
</html>